package edu.thu.studio.ormdesigner.outline.editpart;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import edu.thu.studio.ormdesigner.Activator;
import edu.thu.studio.ormdesigner.model.diagram.Diagram;
import edu.thu.studio.ormdesigner.model.diagram.DiagramSet;
import edu.thu.studio.ormdesigner.util.Properties;

public class DiagramSetOutlineEditPart extends AbstractOutlineEditPart {
    
    /**
     * {@inheritDoc}
     */
    @Override
    @SuppressWarnings("rawtypes")
    protected List getModelChildren() {
        List<Diagram> children = new ArrayList<Diagram>();
        
        DiagramSet diagrams = (DiagramSet) this.getModel();
        
        for (Diagram diagram : diagrams.getObjectList()) {
            children.add(diagram);
        }

        Collections.sort(children);
        return children;
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    protected void refreshOutlineVisuals() {
        this.setWidgetText(Properties.outline_label_diagramset + " (" + this.getModelChildren().size() + ")");
        this.setWidgetImage(Activator.getImage(Properties.icon_diagramset));
    }
    
}
